import { parseTimeDot } from "@/utils/utils.js";
import { getList } from "@/static/js/message.js";
export default {
  data() {
    return {
      parseTimeDot,
      list: [],
      isLoading: false,
    };
  },
  methods: {
    // 获取公告数据
    async getGGData() {
      const res = await getList({
        type: 1,
      });
      if (res.code == 1) {
        uni.stopPullDownRefresh();
        let list = res.data;
        if (list.length > 0) {
          let length = list.length;
          uni.setStorageSync("GGLength", length.toString());
          list.forEach((e) => {
            e.createtime = parseTimeDot(e.createtime, "{m}-{d}");
            e.content = e.content.replace(/<[^>]*>/g, "");
          });
          this.list.push(...list);
        }
      }
      this.isLoading = false;
    },

    go(url) {
      uni.navigateTo({
        url: url,
      });
    },
  },

  onPullDownRefresh() {
    this.isLoading = true;
    this.list = [];
    this.getGGData();
  },
  onLoad(e) {
    this.isLoading = true;
    this.getGGData();
  },
};